/**
 * Created by Administrator on 2017/7/3.
 */
var vm_proContent = avalon.define({
    $id: 'proContent',
    proDetaiData: [],
    bigImg: '',
    smallImg:[],
    changeImg: function (index) {
        this.bigImg = this.proDetaiData.imgUrl[index];
    },
    goContactUs:function () {
        window.location.href = "../index/contactUs.html";
    }
})
getDetailData();
function getDetailData() {
    var id = $.frontEngine.getUrlParameter("id");
    console.log("getDetailData id=" + id);
    var _basePath = pro_detail_url(id);
    console.log(_basePath);
    /*$.frontEngineAjax.ajaxRequest(function (data) {
     vm_proList.menuList = data.menu;
     console.log(JSON.stringify(vm_proList.menuList,null,4));
     }, _basePath)*/
    $.ajax({
        url: pro_detail_url(id),
        dataType: 'json',
        success: function (res, status, xhr) {
            console.log(JSON.stringify(res, null, 4))
            if (res.resultStatus == 100) {
                res.resultData.colourName = formatColor(res.resultData.colour, 1);
                res.resultData.placeName = formatColor(res.resultData.usePlace, 2);
                res.resultData.unlockTypeName = formatColor(res.resultData.unlockType, 3);
                vm_proContent.proDetaiData = [];
                vm_proContent.proDetaiData = res.resultData;
                vm_proContent.smallImg=res.resultData.imageUrl.slice(1);
                console.log(JSON.stringify(vm_proContent.proDetaiData.length, null, 4));
            }
        }
    })
}

function formatColor(id,style) {
    var proAttributes = ff.cache.get('proAttributes');
    var idArr = id.split(",");
    var id_len = idArr.length;
    var colorArr
    if(style == 1){
        colorArr = proAttributes.colour;
    }else if(style == 2){
        colorArr = proAttributes.place;
    }else if(style == 3){
        colorArr = proAttributes.unlockMode;
    }
    var color=[];
    for(var j=0;j<id_len;j++){
        for(var i=0,len=colorArr.length;i<len;i++){
            if(idArr[j]==colorArr[i].id){
                color.push(colorArr[i].label);
            }
        }
    }
    console.log("color==="+color);
    return color;
}